<!-- This comment will put IE 6, 7 and 8 in quirks mode -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Clustering Algorithms</title>
<script type="text/javaScript" src="search/search.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3.0.1/es5/tex-mml-chtml.js"></script>
<script src="../../mlstyle.js"></script>
<link href="../css/besser.css" rel="stylesheet" type="text/css"/>
</head>
<!-- pretty cool: each body gets an id tag which is the basename of the web page  -->
<!--              and allows for page-specific CSS. this is client-side scripted, -->
<!--              so the id will not yet show up in the served source code -->
<script type="text/javascript">
    jQuery(document).ready(function () {
        var url = jQuery(location).attr('href');
        var pname = url.substr(url.lastIndexOf("/")+1, url.lastIndexOf(".")-url.lastIndexOf("/")-1);
        jQuery('#this_url').html('<strong>' + pname + '</strong>');
        jQuery('body').attr('id', pname);
    });
</script>
<body>
    <div id="shark_old">
        <div id="wrap">
            <div id="header">
                <div id="site-name"><a href="../../sphinx_pages/build/html/index.html">Shark machine learning library</a></div>
                <ul id="nav">
                    <li >
                        <a href="../../sphinx_pages/build/html/rest_sources/installation.html">Installation</a>
                    </li>
		    <li >
                        <a href="../../sphinx_pages/build/html/rest_sources/tutorials/tutorials.html">Tutorials</a>
                    </li>
		    <li >
                        <a href="../../sphinx_pages/build/html/rest_sources/benchmark.html">Benchmarks</a>
                    </li>
                    <li class="active">
                        <a href="classes.html">Documentation</a>
                        <ul>
                            <li class="first"></li>
                            <li><a href="../../sphinx_pages/build/html/rest_sources/quickref/quickref.html">Quick references</a></li>
                            <li><a href="classes.html">Class list</a></li>
                            <li class="last"><a href="group__shark__globals.html">Global functions</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </div>
<div id="doxywrapper">
<!--
    <div id="global_doxytitle">Doxygen<br>Documentation:</div>
-->
    <div id="navrow_wrapper">
<!-- Generated by Doxygen 1.9.8 -->
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">Clustering Algorithms<div class="ingroups"><a class="el" href="group__models.html">Models</a></div></div></div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader"> </h2>
<p>A variety of models and algorithms for clustering </p>
<div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-0-trigger" src="closed.png" alt="+"/> Collaboration diagram for Clustering Algorithms:</div>
<div id="dynsection-0-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-0-content" class="dyncontent" style="display:none;">
<div class="center"><img src="group__clustering.png" border="0" usemap="#agroup____clustering" alt=""/></div>
<map name="agroup____clustering" id="agroup____clustering">
<area shape="rect" title=" " alt="" coords="117,5,262,31"/>
<area shape="rect" href="group__models.html" title="Model classes for statistical prediction." alt="" coords="5,5,69,31"/>
</map>
</div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_abstract_clustering.html">shark::AbstractClustering&lt; InputT &gt;</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Base class for clustering.  <a href="classshark_1_1_abstract_clustering.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_centroids.html">shark::Centroids</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Clusters defined by centroids.  <a href="classshark_1_1_centroids.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_clustering_model.html">shark::ClusteringModel&lt; InputT, OutputT &gt;</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Abstract model with associated clustering object.  <a href="classshark_1_1_clustering_model.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_hard_clustering_model.html">shark::HardClusteringModel&lt; InputT &gt;</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Model for "hard" clustering.  <a href="classshark_1_1_hard_clustering_model.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_hierarchical_clustering.html">shark::HierarchicalClustering&lt; InputT &gt;</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Clusters defined by a binary space partitioning tree.  <a href="classshark_1_1_hierarchical_clustering.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_soft_clustering_model.html">shark::SoftClusteringModel&lt; InputT &gt;</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Model for "soft" clustering.  <a href="classshark_1_1_soft_clustering_model.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga18f3e34980a5e92ad240649988ac314c" id="r_ga18f3e34980a5e92ad240649988ac314c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="_d_l_l_support_8h.html#a54b73283f7f70b27fbd8ac5d4621827f">SHARK_EXPORT_SYMBOL</a> std::size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__clustering.html#ga18f3e34980a5e92ad240649988ac314c">shark::kMeans</a> (<a class="el" href="classshark_1_1_data.html">Data</a>&lt; RealVector &gt; const &amp;data, std::size_t k, <a class="el" href="classshark_1_1_centroids.html">Centroids</a> &amp;centroids, std::size_t maxIterations=0)</td></tr>
<tr class="memdesc:ga18f3e34980a5e92ad240649988ac314c"><td class="mdescLeft">&#160;</td><td class="mdescRight">The k-means clustering algorithm.  <br /></td></tr>
<tr class="separator:ga18f3e34980a5e92ad240649988ac314c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga18f3e34980a5e92ad240649988ac314c" name="ga18f3e34980a5e92ad240649988ac314c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga18f3e34980a5e92ad240649988ac314c">&#9670;&#160;</a></span>kMeans()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="_d_l_l_support_8h.html#a54b73283f7f70b27fbd8ac5d4621827f">SHARK_EXPORT_SYMBOL</a> std::size_t shark::kMeans </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classshark_1_1_data.html">Data</a>&lt; RealVector &gt; const &amp;&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::size_t&#160;</td>
          <td class="paramname"><em>k</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classshark_1_1_centroids.html">Centroids</a> &amp;&#160;</td>
          <td class="paramname"><em>centroids</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::size_t&#160;</td>
          <td class="paramname"><em>maxIterations</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The k-means clustering algorithm. </p>
<dl class="section user"><dt></dt><dd>The k-means algorithm takes vector-valued data \( \{x_1, \dots, x_n\} \subset \mathbb R^d \) and splits it into k clusters, based on centroids \( \{c_1, \dots, c_k\} \). The result is stored in a <a class="el" href="classshark_1_1_centroids.html" title="Clusters defined by centroids.">Centroids</a> object that can be used to construct clustering models.</dd></dl>
<dl class="section user"><dt></dt><dd>This implementation starts the search with the given centroids, in case the provided centroids object (third parameter) contains a set of k centroids. Otherwise the search starts from the first k data points.</dd></dl>
<dl class="section user"><dt></dt><dd>Note that the data set needs to include at least k data points for k-means to work. This is because the current implementation does not allow for empty clusters.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">data</td><td>vector-valued data to be clustered </td></tr>
    <tr><td class="paramname">k</td><td>number of clusters </td></tr>
    <tr><td class="paramname">centroids</td><td>centroids input/output </td></tr>
    <tr><td class="paramname">maxIterations</td><td>maximum number of k-means iterations; 0: unlimited </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>number of k-means iterations </dd></dl>

<p class="reference">Referenced by <a class="el" href="_k_means_tutorial_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627">main()</a>.</p>

</div>
</div>
</div><!-- contents -->
</div>
</body>
</html>
